package com.lc;


import java.util.List;

/**
 *  线程类
 */
public class MyWorker extends Thread {

    //线程名字
    private String name;

    //任务集合
    private List<Runnable> tasks;

    public MyWorker(String name, List<Runnable> tasks) {
        //名字给父类线程命名
        super(name);
        this.tasks = tasks;
    }


    @Override
    public void run() {
        //判断集合中是否有任务，有则一直执行
        while(tasks.size() > 0){
            Runnable remove = tasks.remove(0);
            remove.run();
        }
    }
}
